<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>基本信息设置</title>
    {include file="common/linkcss" /}
</head>


<body>

    <div class="container-fluid">
        <div class="row">

            {include file="common/sidebar" /}

            <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">

                <div class="card border-primary  ">
                    <form action="{:url('index')}" enctype="multipart/form-data" method="post">
                        <div class="card-header">
                            <h1 class="page-header">
                                基本信息设置
                            </h1>
                        </div>
                        <div class="card-body">
                            <div class="form-group">
                                <label class="col-form-label col-form-label-lg">公司LOGO</label>
                                <input type="file" class="form-control-file" name="logo" id="upload" accept="image/*">
                                <div style="padding-top:20px;">
                                    {if $info.logo}
                                    <img src="__UPLOADS__/{$info.logo}" id="uploadres" alt="" width="100">
                                    {else/}
                                    <img src="__STATIC__/logo.png" id="uploadres" alt="" width="100">
                                    {/if}
                                </div>
                                <input type="hidden" name="logo" id="logo" value="{$info.logo}">
                            </div>
                            <div class="form-group">
                                <label class="col-form-label col-form-label-lg">公司名称</label>
                                <input class="form-control form-control-lg" name="title" type="text" placeholder="" value="{$info.title}" required autofocus>
                            </div>
                            <div class="form-group">
                                <label class="col-form-label col-form-label-lg">公司地址</label>
                                <input class="form-control form-control-lg" id="adrress" name="adrress" type="text" value="{$info.adrress}" placeholder="" required>
                            </div>
                            <div class="row">
                                <div class="col-lg-6 form-group ">
                                    <label class="col-form-label col-form-label-lg" for="storename">
                                        公司坐标经纬度
                                        <button type="button" onclick="getLocation()" class="btn btn-primary btn-sm">上方输入公司地址，点击此处获取</button>
                                    </label>
                                    <input type="text" id="lat" name="lat" class="form-control form-control-lg" value="{$info.lat}" readonly>
                                </div>
                                <div class="col-lg-6 form-group " style="padding-top:3px;">
                                    <label class="col-form-label col-form-label-lg" for="storename">&nbsp;</label>
                                    <input type="text" id="lng" name="lng" value="{$info.lng}" class="form-control form-control-lg" readonly>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-form-label col-form-label-lg">公司电话</label>
                                <input class="form-control form-control-lg" name="tel" type="text" placeholder="" value="{$info.tel}" required>
                            </div>
                            {if session('adminLevel')}
                            <div class="form-group">
                                <label class="col-form-label col-form-label-lg">公司网站【需在小程序后台设置安全地址并必须是HTTPS协议，才能在小程序访问】</label>
                                <input class="form-control form-control-lg" name="web" type="text" placeholder="" value="{$info.web}" required>
                            </div>
                            <div class="form-group">
                                <label class="col-form-label col-form-label-lg">小程序APPID</label>
                                <input class="form-control form-control-lg" name="wechatappid" type="text" placeholder="" value="{$info.wechatappid}" required>
                            </div>
                            <div class="form-group">
                                <label class="col-form-label col-form-label-lg">小程序SECRET</label>
                                <input class="form-control form-control-lg" name="wechatsecret" type="text" placeholder="" value="{$info.wechatsecret}" required>
                            </div>
                            {/if}
                        </div>
                        <div class="card-footer">
                            <input type="hidden" name="id" value="{$info.id}">
                            <button type="submit" class="btn btn-primary btn-lg">确认提交</button>
                        </div>
                    </form>
                </div>

            </div>
            <!-- main end -->


        </div>
    </div>
    <!-- container end -->
    <script src="https://map.qq.com/api/js?v=2.exp&key=J32BZ-X4WYW-XBNRG-OY7LI-DBKTH-JSFMT"></script>
    <script>
        geocoder = new qq.maps.Geocoder({
            complete: function (result) {
                $('#lat').val(result.detail.location.lat);
                $('#lng').val(result.detail.location.lng);
            },
            error: function (r) {
                alert('获取失败，请输入正确地址重试')
            }
        });

        function getLocation() {
            var address = $("#adrress").val();
            geocoder.getLocation(address);
        }
    </script>

    <script>
        $('#upload').change(function () {
            var formData = new FormData();
            formData.append("file", $(this).get(0).files[0]);
            $.ajax({
                url: "{:url('index/upload')}",
                type: 'POST',
                data: formData,
                cache: false,
                contentType: false, //不可缺
                processData: false, //不可缺
                success: function (data) {
                    $('#uploadres').attr('src', '__UPLOADS__/' + data);
                    $('#logo').val(data);
                }
            });
        })
    </script>
</body>

</html>